import request from '@/utils/request'

export default {
  // 获取Neo4j的所有节点及其相关关系
  getAllNode(){
    return request({
      url: `/courses/getAllNode`,
      method: 'get'
    })
  },
  // 导出课程信息
  exportCourse(){
    return request({
      url: `/courses/exportCourse`,
      method: 'get',
      responseType: 'blob'
    })
  },
  // 查询所有的课程名称和id
  getCoursesIdAndName(){
    return request({
      url: `/courses/getCoursesIdAndName`,
      method: 'get'
    })
  },

  // 根据当前课程id查询可以添加的后继课程列表
  getCanBeAddedNextCourseList(currentCourseId){
    return request({
      url: `/coursesRelation/getCanBeAddedNextCourseList/${currentCourseId}`,
      method: 'get'
    })
  },

  // 组合条件查询课程信息
  getCoursesPage(current, limit, courseQueryObj) {
    return request({
      url: `/courses/pageCoursesCondition/${current}/${limit}`,
      method: 'post',
      data: courseQueryObj
    })
  },

  //删除课程，及该课程下的所有子信息
  deleteCourse(courseId) {
    return request({
      url: `/courses/deleteCourse/${courseId}`,
      method: 'delete',
    })
  },

  //修改课程信息
  updateCourseInfo(courses) {
    return request({
      url: `/courses/updateCourse`,
      method: 'put',
      data: courses
    })
  },

  //增加新的课程
  addCourse(courses) {
    return request({
      url: `/courses/addCourse`,
      method: 'post',
      data: courses
    })
  },

  // 根据课程id查询后继课程列表
  getNextCourseList(currentCourseId){
    return request({
      url: `/coursesRelation/getNextCourseList/${currentCourseId}`,
      method: 'get'
    })
  },

  // 增加新的后继课程
  addCourseRelation(newNextCourse){
    return request({
      url: `/coursesRelation/addCourseRelation`,
      method: 'post',
      data:newNextCourse
    })
  },

  // 删除后继课程关系
  deleteCourseRelation(currentCourseId,nextCourseId){
    return request({
      url: `/coursesRelation/deleteCourseRelation/${currentCourseId}/${nextCourseId}`,
      method: 'delete',
    })
  }
}
